var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    }; Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("BaseModuleUI"),
    n = e("GlobalParams"),
    i = e("AudioManager"),
    r = e("CommonHelper"),
    s = e("Game"),
    l = e("GetZsViewUI"),
    _ = e("sdkConfig"),
    c = e("AD"),
    d = e("BigAdNative"),
    h = cc._decorator,
    u = h.ccclass,
    p = h.property,
    m = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.shop_content_node = null),
                (t.free_coin_node = null),
                (t.native_node = null),
                (t.native_btn_node = null),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.initView = function () {
                e.prototype.initView.call(this),
                    (this.native_btn_node.active = this.native_node.active =
                        _.default.platform == _.EPlatform.OPPO && !c.default.getInstance().getGameTestVersion()),
                    this.showFreeInfo(),
                    this.showCoinInfo();
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "free_btn":
                        if (
                            _.default.platform == _.EPlatform.OPPO &&
                            c.default.getInstance().getNativeImageErrorControl()
                        )
                            return void this.native_node.getComponent(d.default).nativeClick();
                        var o = n.GlobalParams.PlayerInfo.value;
                        (o.free_coin = new Date().toLocaleDateString()),
                            (n.GlobalParams.PlayerInfo.value = o),
                            this.showFreeInfo(),
                            this.uiManager.addCoinNum(200);
                }
            }),
            (t.prototype.showFreeInfo = function () {
                (this.free_coin_node.getComponent(cc.Button).interactable =
                    n.GlobalParams.PlayerInfo.value.free_coin != new Date().toLocaleDateString()),
                    (this.free_coin_node.children[0].getComponent(cc.Label).string =
                        n.GlobalParams.PlayerInfo.value.free_coin != new Date().toLocaleDateString()
                            ? "领  取"
                            : "已领取");
            }),
            (t.prototype.showCoinInfo = function () {
                for (var e = 0; e < this.shop_content_node.childrenCount; e++) {
                    var t = this.shop_content_node.children[e],
                        o = s.default.shop_coin_info[e];
                    t.name = "coin_" + e;
                    var a = t.children[0].getChildByName("dis_count");
                    (a.active = 1 != o.discount),
                        (a.children[0].getComponent(cc.Label).string = 10 * o.discount + "折"),
                        (t.children[1].children[1].getComponent(cc.Label).string = "" + o.zs * o.discount),
                        (t.children[0].getChildByName("coin_num").getComponent(cc.Label).string = "+ " + o.coin),
                        t.children[1].on("click", this.buyCoinInfo, this);
                }
            }),
            (t.prototype.buyCoinInfo = function (e) {
                i.default.ButtonSound();
                var t = e.node.parent.name,
                    o = Number(r.default.getNameType(t, "coin_")),
                    a = s.default.shop_coin_info[o];
                n.GlobalParams.PlayerInfo.value.zs >= a.zs * a.discount
                    ? (this.uiManager.addZsNum(a.zs * a.discount * -1), this.uiManager.addCoinNum(a.coin))
                    : this.uiManager.showPopup("GetZsViewUI", function (e) {
                        e.getComponent(l.default).showPopupInfoView(0);
                    });
            }),
            oo([p(cc.Node)], t.prototype, "shop_content_node", void 0),
            oo([p(cc.Node)], t.prototype, "free_coin_node", void 0),
            oo([p(cc.Node)], t.prototype, "native_node", void 0),
            oo([p(cc.Node)], t.prototype, "native_btn_node", void 0),
            oo([u], t)
        );
    })(a.default);
o.default = m;
